package com.right.health.app.ui.medical;

import android.os.Bundle;
import android.widget.GridView;
import android.widget.TextView;

import com.magic.basic.activity.BaseActivity;
import com.right.health.app.R;
import com.right.health.app.app.App;
import com.right.health.app.bean.HomeItem;
import com.right.health.app.common.DataCommon;
import com.right.health.app.ui.medical.adapter.MedicalTypeAdapter;

/*
 * Created by hopeliao on 2019-09-30
 *
 */
public class MedicalTypeActivity extends BaseActivity {

    private MedicalTypeAdapter mAdapter;

    private TextView mNameTv, mSexTv;

    @Override
    public void onCreate(Bundle bundle, String s) {
        setContentView(R.layout.medical_type);
    }

    @Override
    public void findView() {
        mNameTv = (TextView) findViewById(R.id.tv_name);
        mSexTv = (TextView) findViewById(R.id.tv_sex);

        GridView gridView = (GridView) findViewById(R.id.gridview);
        mAdapter = new MedicalTypeAdapter(this);
        gridView.setAdapter(mAdapter);
        gridView.setOnItemClickListener((parent, view, position, id) -> {
            HomeItem item = (HomeItem)parent.getItemAtPosition(position);
            if(item != null) {
                switch (item.name) {
                    case "过敏史":
                        startIntent(AllergyListActivity.class);
                        break;
                    case "婚育史":
                        startIntent(MarriageHistoryActivity.class);
                        break;
                    case "手术史":
                        startIntent(SurgeryListActivity.class);
                        break;
                    case "家族史":
                        startIntent(FamilyMedicalActivity.class);
                        break;
                    case "既往史":
                        startIntent(PastActivity.class);
                        break;
                }
            }
        });
    }

    @Override
    public void initialize() {
        mAdapter.setDataSource(DataCommon.getMedicalType());

        mNameTv.setText(App.getInstance().getCurrentMember().name);
        mSexTv.setText(DataCommon.getSex(App.getInstance().getCurrentMember().sex));
    }
}
